#! /usr/bin/python

import math

def sieve(n):
    ll = range(n)
    for i in range(2, int(math.sqrt(n) + 1)):
	for j in range(i**2, n, i):
	    ll[j] = 0
    return [p for p in ll if p != 0]

primes = sieve(10**5)
print primes[0:20]
ll = range(len(primes))
primes.remove(1)
primes.remove(2)
primes.remove(3)
primes.remove(5)

def isPrime(n):
    if n == 2 or n ==3 or n==5 or n==7: return True
    if n == 1 or n%2 == 0 or n%3 == 0: return False
    for i in range(5, int(math.sqrt(n) + 1), 6):
	if n%i == 0 or n%(i+2) == 0: 
	   #print i
	   return False
    return True

def A(n):
    x, k = 1, 1
    while x != 0:
        x = (x*10 + 1)%n
	k += 1
    return k

prime2 = set()

for i in range(0, len(primes)):
    k = A(primes[i])
    #print k
    #pp = int(math.log(k))
    #if k%10 == 0: prime2.add(primes[i])

#for n in range(1, 30):
#    for i in range(0, len(primes)):
#        if pow(10, 10**n, primes[i]) == 1:
#	   prime2.add(primes[i]) 

print len(prime2)
print sum(primes) - sum(prime2)
#for i in range(len(primes)):
#    if ll[i] != 0:
#	print primes[i]
